package com.guhappy.stockutil;
import java.io.InputStream;
import java.net.URL;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

public class UpdateStokUntilJson {
	 public static void main(String[] args) throws Exception {
	        JAXBContext jc = JAXBContext.newInstance(Stock.class);
	       // select * from yahoo.finance.quotes where symbol in ("600005.SS")
	        Unmarshaller unmarshaller = jc.createUnmarshaller();
	        StringBuffer buff=  new StringBuffer("select * from yahoo.finance.quotes where symbol = ");
	        URL url = new URL("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22600005.SS%22)&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys");
	        InputStream xmlStream = url.openStream();
	        Stock stock = (Stock) unmarshaller.unmarshal(xmlStream);

	        Marshaller marshaller = jc.createMarshaller();
	        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
	        marshaller.marshal(stock, System.out);
	    }

}
